using System;
using Coderoom.ScrumPlanner.Data.Contracts;
using Coderoom.ScrumPlanner.Domain;
using Coderoom.ScrumPlanner.Resources;

namespace Coderoom.ScrumPlanner.Data
{
	public sealed class TaskService : Service<ITaskRepository>
	{
		public TaskService(ITaskRepository repository) : base(repository) {}

		public TaskCollection GetTasks(Guid userStoryId)
		{
			return Repository.GetTasks(userStoryId);
		}

		public Task GetTask(Guid taskId)
		{
			return Repository.GetTask(taskId);
		}

		public void CreateTask(Task task)
		{
			if (task == null)
				throw new ArgumentNullException("task");

			if (string.IsNullOrEmpty(task.Title))
				throw new ArgumentException(ExceptionMessages.ArgumentException_TaskTitleIsNullOrEmpty);

			Repository.CreateTask(task);
		}

		public bool DeleteTask(Guid taskId)
		{
			return Repository.DeleteTask(taskId);
		}
	}
}